package com.smartwebx.ha.web.admin.module.screen.user;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.dataresolver.Params;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.smartwebx.ha.biz.assign.HaUserManager;
import com.smartwebx.ha.dal.assign.bean.HaUser;
import com.smartwebx.ha.usebean.Paging;
import com.smartwebx.ha.usebean.json.HaUserJson;
import com.smartwebx.ha.util.JsonHelper;
import com.smartwebx.ha.web.admin.common.HaUserSys;

public class AjaxTableUser {
	@Autowired
	private HttpServletResponse response;
	@Autowired
	private HaUserManager haUserManager;
	@Autowired
	private HttpSession session;
	
	public void execute(@Params Paging page) throws Exception{
		response.setContentType("application/json");
		PrintWriter out=response.getWriter();
		ObjectMapper mapper=JsonHelper.objectMapperMixinOption(HaUser.class, HaUserJson.class);
		HaUserSys loginUser = (HaUserSys) session.getAttribute("haUser");
		mapper.writeValue(out, haUserManager.queryUserByPage(page,loginUser.getGroupId(),loginUser.getCode()));
	}

}
